function submitPage(obj) {
	var ids = "";
	$("[name='ids']").each(function() {
		ids += $(this).val() + ",";
	});
	API.submitExternal({"ids":ids}, function(res) {
		UTIL.releaseButton(obj);
		if (res.code == '0') {
			if(res.desc ){
				alert(res.desc);
			}
			window.location.reload();
			UTIL.releaseButton(obj);
			return true;
		} else {
			alert(res.desc);
		}
	});
}

function changeShowDisease(obj, id) {
	var _obj = $(obj);
	var disease = _obj.val();

	var param = {
		"id": id,
		"disease": disease
	}

	API.checkExternalDisease(param, function(res) {
		if(res.code == 0) {
			API.changeExternalDisease(param, function(res) {
				if(res.code == 0) {
				}else{
					alert(res.desc);
				}
			});
		} else if(res.code == 30001){
			if(confirm(res.desc)){
				API.changeExternalDisease(param, function(res) {
					if(res.code == 0) {
					} else{
						alert(res.desc);
					}
				});
			}
		}
	});
}
function changeCategory(obj, id) {
	var _obj = $(obj);
	var category = _obj.val();

	var param = {
		"id": id,
		"category": category
	}

	API.changeExternalCategory(param, function(res) {
		if(res.code == 0) {
			
		} else if(res.code == 30001){
			alert(res.desc);
		}
	});
}


function init(obj){
	$("#initButton").val("刷新中");

	var param = {
			
	};
	API.initExternalDisease(param, function(res) {
		$("#initButton").val("刷新完成");
		if(res.code == 0) {
			alert("刷新成功");
			location.reload();
		}else{
			alert("刷新失败");
		}
	});
	
}

function initDisease(obj){
	$("#initDiseaseButton").val("刷新中");

	var param = {
			
	};
	API.initExternal(param, function(res) {
		$("#initDiseaseButton").val("刷新完成");
		if(res.code == 0) {
			alert("刷新成功");
			location.reload();
		}else{
			alert("刷新失败");
		}
	});
	
}
function changeDisable(obj){
	var disease = $("#"+$(obj).attr("dataId")).val();
	if(!disease){
		alert("疾病名不能为空");
		return;
	}
	var param = {
		id:$(obj).attr("dataId"),
		disable:$(obj).val()
	};
	API.changeExternalDisable(param,function(res) {
		if (res.code == '0') {
		}else{
			location.reload();
			alert(res.desc);
		}
	});
}


function elementExport(obj) {
	if(UTIL.checkButton(obj)) {
		window.location.href="/icd/external_disease_export.do";
		UTIL.releaseButton(obj);
	}
}



function diseaseImport(obj) {
	$("#file").click();
}
$("#file").change(function(){
	$("#Import").val("导入中");
	var url ="/icd/external_disease_import.do";
	importFile("#file",url,null);
});

/*
$("#file").change(fileChange);

function fileChange(){
	$("#importButton").val("导入中");
	var file = $("#file").val();
	if(file) {
		var strFileName=file.replace(/^.+?\\([^\\]+?)(\.[^\.\\]*?)?$/gi,"$1");  //正则表达式获取文件名，不带后缀
		var FileExt=file.replace(/.+\./,"");   //正则表达式获取后缀
		
		
		// 后缀只能是xlsx，其他不处理
		if(FileExt != 'xlsx') {
			alert("请上传xlsx后缀的Excel文件");
			return false;
		}
		
		$.ajaxFileUpload({
			url: '/icd/external_disease_import.do',
			secureuri: false,
			fileElementId: 'file',
			dataType: 'json',
			data: {"property" : strFileName},
			success: function(data) {
				$("#importButton").val("导入完成");
				$("#file").after($("#file").clone().val(""));
				$("#file").remove();
				$("#file").change(fileChange);
				if(data.code == '0') {
					alert(data.desc);
					getList();
				} else {
					alert(data.desc);
				}
			}
		});
	}
}
*/